package club.monkeywood.repository;

import club.monkeywood.dataobject.BuyerRecommend;
import club.monkeywood.dto.buyer.BuyerRecommendDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface BuyerRecommendRepository extends JpaRepository<BuyerRecommend, Integer> {

    @Query(value = "select new club.monkeywood.dto.buyer.BuyerRecommendDTO(" +
            " a.ratingId, a.productionId, b.name) " +
            " from BuyerRecommend a, Production b " +
            " where a.productionId = b.id " +
            " and b.sellerId=:sellerId ")
    List<BuyerRecommendDTO> queryBuyerRecommend(@Param("sellerId") Integer sellerId);
}
